﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.TD
{
	public class OdDxfCode : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDxfCode(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDxfCode obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDxfCode()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDxfCode(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public static OdDxfCode.Type _getType(int code)
		{
			OdDxfCode.Type result = (OdDxfCode.Type)TD_DbPINVOKE.OdDxfCode__getType(code);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDxfCode() : this(TD_DbPINVOKE.new_OdDxfCode(), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;

		public enum Type
		{
			Unknown,
			Name,
			String,
			Bool,
			Integer8,
			Integer16,
			Integer32,
			Double,
			Angle,
			Point,
			BinaryChunk,
			LayerName,
			Handle,
			ObjectId,
			SoftPointerId,
			HardPointerId,
			SoftOwnershipId,
			HardOwnershipId,
			Integer64
		}
	}
}
